﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VRacer.Packets
{
    public class ContinueTurnPacket : PacketBase
    {
        private int _flags;
        private int _nextPlayerID;
        private int _turns = 0;

        

        public ContinueTurnPacket()
            : base(PacketType.ContinueTurn)
        {
            base.Length += 12;
        }

        public bool IsNewTurn
        {
            get { return (_flags & 0x0001) > 0; }
            set
            {
                if (value)
                    _flags |= 0x0001;
                else
                    _flags &= 0x1110;
            }
        }

        public int NextPlayerID
        {
            get { return _nextPlayerID; }
            set { _nextPlayerID = value; }
        }

        public int Turns
        {
            get { return _turns; }
            set { _turns = value; }
        }

        public override void Read(System.IO.BinaryReader reader)
        {
            base.Read(reader);

            _flags = reader.ReadInt32();
            _turns = reader.ReadInt32();
            _nextPlayerID = reader.ReadInt32();
        }

        public override void Write(System.IO.BinaryWriter writer)
        {
            base.Write(writer);

            writer.Write(_flags);
            writer.Write(_turns);
            writer.Write(_nextPlayerID);
        }

    }
}
